package proxy.dynamic.jdk.factory;

import proxy.dynamic.jdk.SendMsg;
import proxy.dynamic.jdk.handler.InvokeSendHandler;

import java.lang.reflect.Proxy;

/**
 * @JDKProxyFactory:
 * @author: ZBoHang
 * @time: 2021/9/30 16:49
 */
public class JDKProxyFactory {

    public static <T extends SendMsg> T getProxy(Object target) {
        return (T) Proxy.newProxyInstance(
                target.getClass().getClassLoader(),
                target.getClass().getInterfaces(),
                new InvokeSendHandler(target)
        );
    }
}
